#!/bin/bash
dir=$(dirname $0)
cd ${dir}

MODULE=app
task_status=$(ps -ef | grep ${MODULE} | grep -v grep | wc -l)
if [[ task_status -ne 0 ]];then
    echo $(date) "task is running, will stop it"
    ps -ef | grep ${MODULE} | grep -v grep | awk '{print $2}' | xargs kill -9
    echo $(date) "stop done......"
else
    echo $(date) "task not running, no need to stop"
fi